String.prototype.format = function () {
    if (arguments.length === 0) return this;
    var obj = arguments[0];
    var parentKeys = arguments[1];
    if (!parentKeys) {
        parentKeys = [];
    }
    var s = this;
    for (var key in obj) {
        var val = obj[key];

        if (val instanceof Array) {

        } else if (val instanceof Object) {
            parentKeys.push(key);
            s = s.format(val, parentKeys);
        } else {
            var property = key;
            if (parentKeys.length > 0) {
                property = parentKeys.join('.') + '.' + key;
            }
            s = s.replace(new RegExp("\\{\\{" + property + "\\}\\}", "g"), val);
        }
    }
    return s;
}